<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

const handleSelect = (key) => {
  switch (key) {
    case '1':
      router.push('/main')
      break
    case '2':
      router.push('/articleView')
      break
    case '3':
      router.push('/GalleryView')
      break
    case '4':
      router.push('/ToolsView')
      break
  }
}
</script>

<template>
  <header class="header">
    <el-menu
      mode="horizontal"
      background-color="#242424"
      text-color="#fff"
      active-text-color="#ffd04b"
      :ellipsis="false"
      @select="handleSelect"
    >
      <div class="menu-container">
        <el-menu-item class="logo">瞎捣鼓的玩意</el-menu-item>
        <div class="nav-items">
          <el-menu-item index="1">首页</el-menu-item>
          <el-menu-item index="2">文章</el-menu-item>
          <el-menu-item index="3">图库</el-menu-item>
          <el-menu-item index="4">工具</el-menu-item>
        </div>
        <el-menu-item class="logo"></el-menu-item>
      </div>
    </el-menu>
  </header>
</template>

<style scoped>
.header {
  position: fixed;
  top: 0;
  z-index: 1000;
  width: 100%;
}

.menu-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

.nav-items {
  display: flex;
  justify-content: center;
  flex-grow: 1;
}

:deep(.el-menu) {
  width: 100%;
  padding: 0;
  background-color: #2f2e31 !important;
  border-bottom: none !important;
}

:deep(.el-menu-item) {
  font-size: 15px;
  font-weight: bold;
  padding: 0 20px;
  height: 60px;
  line-height: 60px;
  color: #fff !important;
}

:deep(.el-menu-item.is-active) {
  color: #ffd04b !important;
  background-color: #1c1c1c !important;
}

.logo {
  font-size: 1.2em;
  font-weight: bold;
  white-space: nowrap;
  flex-shrink: 0;
  width: 6em;
}

/* Responsive Design */
@media (max-width: 768px) {
  .menu-container {
    flex-direction: column;
    padding: 0;
  }

  .nav-items {
    width: 100%;
    justify-content: center;
  }

  :deep(.el-menu-item) {
    padding: 0 15px;
    font-size: 14px;
  }

  .logo {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .nav-items {
    flex-wrap: wrap;
  }

  :deep(.el-menu-item) {
    padding: 0 10px;
    font-size: 13px;
  }
}
</style>

